{include file='common/head'}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>推荐(发现)</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <xblock style="height: 40px">

        <span class="x-right" style="line-height:40px;height: 40px;">共有数据：{$tiao} 条</span>
    </xblock>
    <form class="layui-form" action="">
    <table class="layui-table">
        <thead>
        <tr style="text-align: center">
            <th>NO</th>
            <th>信息ID</th>
            <th>类型</th>
            <th style="text-align: center">图片</th>
            <th style="text-align: center">标题(前12字)</th><!--显示12个字-->
            <th>供应数量</th>
            <th>单位</th>
            <th style="text-align: center">价格</th>
            <th style="text-align: center">摘要(前20字)</th><!--前20个字-->
            <th>用户</th>
            <th>认证状态</th>
            <th style="text-align: center">发布时间</th>
            <th>信息状态</th>
            <th style="text-align: center">操作|置顶</th>
        </tr>
        </thead>
        <tbody>
        {volist name="rs" id="rs"}
        <tr style="text-align: center">
            <td>{$key+1}</td>
            <td>{$rs.mid}</td>
            <td>{if $rs.type==1}产品{else/}文章{/if}</td>
            <td><?php $str=$rs['picture'];
                        $a=explode(",",$str);?><img src="/upload/message/{$a['0']}" width="50" height="50"></td>
            <td>{$rs['title']|mb_substr=0,12,'utf-8'}</td>
            <td>{$rs.number}</td>
            <td>{if $rs.type==2}{elseif $rs.unit==1}吨{elseif $rs.unit==2}公斤{elseif $rs.unit==3}斤{else/}个{/if}</td>
            <td>{if $rs.type==2}{elseif $rs.unit==1}{$rs.price}元/吨{elseif $rs.unit==2}{$rs.price}元/公斤{elseif $rs.unit==3}{$rs.price}元/斤{else/}{$rs.price}元/个{/if}</td>
            <td>{$rs['content']|mb_substr=0,20,'utf-8'}</td>
            <td>{if $rs.uname==''}{$rs.nickname}{else/}{$rs.uname}{/if}</td>
            <td>{if $rs.rflg==1}已认证{else/}未认证{/if}</td>
            <td>{$rs.createtime}</td>
            <td><?php if($rs['stoptime']<date("Y-m-d H:i:s"))
                {
                    echo '过期';
                }
                else
                {
                    if($rs['mflg']=='0')
                    {
                        echo '锁定';
                    }
                    else
                    {
                         echo '正常';
                    }
                }?></td>
            <td class="td-manage">
                <a title="上移" onclick="member_del(this,'{$rs.mid}')" href="javascript:;">
                    <i class="layui-icon">&#xe62f;</i><span style="color: mediumblue">上移</span>
                </a>
                <a title="下移" onclick="member_xia(this,'{$rs.mid}')" href="javascript:;">
                    <i class="layui-icon">&#xe601;</i><span style="color: mediumblue">下移</span>
                </a>
                <input type="checkbox" <?php if ($rs['state'] ==1): ?>  checked="" <?php endif; ?> name="status[]" lay-skin="switch" lay-filter="switchSuodoing" lay-text="置顶|关闭"/ value="{$rs.mid}">
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    </form>
    <div class="page">
        <div>
            {$page}
        </div>
    </div>

</div>
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;
        //执行一个laydate实例
        form.on('switch(switchSuodoing)', function(data){
            var id = data.value;
            //alert(5555);return false;
            $.ajax({
                url: "{:url('index/xinxi/faxianstate')}",
                type: "post",
                dataType: "JSON",
                data: {mid: id},
                success: function (res) {
                    if (res ==1) {
                        layer.msg('操作成功！');
                        setTimeout(function () {
                            location.reload();
                        }, 1000);
                        return false;
                    } else {
                        layer.msg('操作失败！');
                        /*setTimeout(function () {
                            location.reload();
                        }, 1000);*/
                        return false;
                    }
                }
            });
        });
    });

    //上移
    function member_del(obj,id){
       // layer.confirm('确认要上移？',function(index){
            //$(obj).parents("tr").remove();
            //layer.msg('已删除!',{icon:1,time:1000});
            $.ajax({
                url: "{:url('index/xinxi/shangyi')}",
                type: "post",
                dataType: "JSON",
                data: {mid: id},
                success: function (res) {
                    if (res.code ==1) {
                        layer.msg(res.msg);
                        setTimeout(function () {
                            location.reload();
                        }, 1000);
                        return false;
                    } else {
                        layer.msg(res.msg);
                        //console.log(res);
                        /*setTimeout(function () {
                            location.reload();
                        }, 1000);*/
                        return false;
                    }
                }
            });
       // });
    }

    //下移
    function member_xia(obj,id){
        //layer.confirm('确认要下移？',function(index){
            //$(obj).parents("tr").remove();
            //layer.msg('已删除!',{icon:1,time:1000});
            $.ajax({
                url: "{:url('index/xinxi/xiayi')}",
                type: "post",
                dataType: "JSON",
                data: {mid: id},
                success: function (res) {
                    //console.log(res);
                    if (res.code ==1) {
                        layer.msg(res.msg);
                        setTimeout(function () {
                            location.reload();
                        }, 1000);
                        return false;
                    } else {
                        layer.msg(res.msg);
                        //console.log(res);
                        /*setTimeout(function () {
                            location.reload();
                        }, 1000);*/
                        return false;
                    }
                }
            });
       // });
    }

    function delAll (argument) {

        var data = tableCheck.getData();

        layer.confirm('确认要删除吗？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
    }
</script>

</body>

</html>